<!DOCTYPE html>
<html>
	<head>
		<title>Linking tables</title>
		<link rel="stylesheet" href="../../../codebase/webix.css" type="text/css" charset="utf-8">
		<script src="../../../codebase/webix.js" type="text/javascript" charset="utf-8"></script>

		<link rel="stylesheet" type="text/css" href="../common/samples.css">
		<script src="../common/testdata.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<div class='header_comment'>Linking tables</div>
		<div class='sample_comment'>Select some record in the master table and see changes in the slave table.</div>
		</br>
		<div class='sample_comment'>Master grid</div>
		<div id="testA"></div>
		<hr>
		<div class='sample_comment'>Slave grid</div>
		<div id="testB"></div>
		<script type="text/javascript" charset="utf-8">
		webix.ready(function(){
			grida = webix.ui({
				container:"testA",
				view:"datatable",
				columns:[
					{ id:"rank",	header:"", css:"rank",  		width:50},
					{ id:"title",	header:"Film title", width:200  },
					{ id:"year",	header:"Released" , width:80	},
					{ id:"votes",	header:"Votes", 	width:100	}
				],
				autoheight:true,
				autowidth:true,
				select:"row",

				data:small_film_set
			});	

			gridb = webix.ui({
				container:"testB",
				view:"datatable",
				columns:[
					{ id:"year",	header:"Year", 		width:50},
					{ id:"votes",	header:"Votes",		width:70  }
				],
				autoheight:true,
				autowidth:true
			});	
			
			gridb.bind(grida, function(slave, master){
				if (!master) return false;
				return master.id == slave.movie;
			});		

			
			gridb.parse(linked_set);
			grida.select(grida.getFirstId());
			
		});
		</script>
	</body>
</html>